package com.xiaobai.zhuangxiuguanjia.activities;

import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.ProgressBar;

import com.xiaobai.zhuangxiuguanjia.R;

public class FreeActivity extends AppCompatActivity {

    private ProgressBar mydemandProgress;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_free);

        ActionBar actionBar = getSupportActionBar();
        actionBar.setIcon(R.mipmap.abc_ic_ab_back_mtrl_am_darker);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setTitle("申请免费报价");

        mydemandProgress = (ProgressBar) findViewById(R.id.free_progress);
        mydemandProgress.setMax(100);

        final WebView mydemand = (WebView) findViewById(R.id.free_webview);
        mydemand.setWebChromeClient(new WebChromeClient() {
            @Override
            public void onProgressChanged(WebView view, int newProgress) {
                if (newProgress == 100)
                    mydemandProgress.setVisibility(View.GONE);
                else {
                    if (mydemandProgress.getVisibility() == View.GONE)
                        mydemandProgress.setVisibility(View.VISIBLE);

                    mydemandProgress.setProgress(newProgress);
                }

                super.onProgressChanged(view, newProgress);
            }
        });
        mydemand.getSettings().setJavaScriptEnabled(true);
        mydemand.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
        mydemand.getSettings().setUseWideViewPort(true);
        mydemand.getSettings().setLoadWithOverviewMode(true);
        mydemand.loadUrl("http://m.to8to.com/yezhu/zxbj.php?to8to_from=baiduapp&fromapp=app&pro_s_sourceid=1&device_src=3&ptag=30032_1_2_1");
    }
}
